<template>
  <div class="app-container">

    <el-input v-model="input" placeholder="请输入内容" style="width: 180px"></el-input>
    <el-button icon="el-icon-search" @click="getList(1)"></el-button>

    <!-- 表格 -->
    <el-table
      :data="list"
      border
      fit
      highlight-current-row>

      <el-table-column
        label="序号"
        width="70"
        align="center" >
        <template slot-scope="scope">
          {{ this.count=(page - 1) * limit + scope.$index + 1 }}
        </template>
      </el-table-column>

      <el-table-column prop="kind" label="类别" width="80" />
      <el-table-column type="String" prop="content" label="内容" sortable >
        <template slot-scope="scope" class="ql-editor">
          <p v-html='scope.row.content'></p>
        </template>
      </el-table-column>

      <el-table-column prop="title" label="标题" />

      <el-table-column prop="gmtCreate" label="添加时间" width="160"/>

      <el-table-column prop="sort" label="排序" width="60" />

      <el-table-column label="操作" width="200" align="center">
        <template slot-scope="scope">
          <router-link :to="'/teacher/edit/'+scope.row.id">
            <el-button type="primary" size="mini" icon="el-icon-edit">修改</el-button>
          </router-link>
          <el-button type="danger" size="mini" icon="el-icon-delete" @click="removeDataById(scope.row.id)">删除</el-button>
        </template>
      </el-table-column>
    </el-table>
    <!-- scope.row.id 获取该行内容的id -->

    <!-- 分页 -->
    <!-- 需要修改的地方@current-change="getList"  -->
    <el-pagination
      :current-page="page"
      :page-size="limit"
      :total="total"
      style="padding: 30px 0; text-align: center;"
      layout="total, prev, pager, next, jumper"
      @current-change="getList"
    />
  </div>
</template>
<script>
import article from "@/api/article/article"
export default{
  data(){
    return{
      list:null,//查询后的接口集合
      page:1,//当前页
      limit:3,//每页记录总数
      total:'',//总记录数
      input: '',
      count:0,
    }
  },
  created(){
  },
  methods:{
    getList(page=1){
      this.page=page
      article.search(this.input,this.page,this.limit)
        .then(response=>{
          this.list=response.data.rows
          this.total=response.data.total;
        })
    }
  }
}
</script>
